<template>
  <div id="myeditor"></div>
</template>

<script setup>
import { onMounted, defineEmits } from "vue";
import E from "wangeditor";
const emit = defineEmits(["even"]);

const props = defineProps({
  content:String
});

onMounted(() => {
  const editor = new E("#myeditor");
  editor.create();

  // 设置初始值 : editor.txt.html(值) 进行重新设置编辑器内容
  props.content &&  editor.txt.html(props.content)
 

  editor.config.onchange = (newHtml) => {
    console.log("打印change后最新的newHtml", newHtml);

    // 子传父
    emit("even", newHtml);
  };
});
</script>

<style scoped lang="scss">
#myeditor {
  width: 1200px;
}
</style>
